package com.longcai.piaojia.adapter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.longcai.piaojia.R;
import com.longcai.piaojia.conn.FeedbackDetailListGet;
import com.zcx.helper.bound.BoundView;
import com.zcx.helper.bound.BoundViewHelper;
import com.zcx.helper.scale.ScaleScreenHelperFactory;

import java.util.List;

/**
 * Created by Administrator on 2016/12/2.
 */
public class FeedbackDetailAdapter extends ArrayAdapter<FeedbackDetailListGet.FeedbackDetail> {

    private LayoutInflater layoutInflater;
    private Context context;

    public FeedbackDetailAdapter(Context context, List<FeedbackDetailListGet.FeedbackDetail> lists) {
        super(context, 0, lists);

        layoutInflater = LayoutInflater.from(context);

        this.context = context;

    }


    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        FeedbackDetailListGet.FeedbackDetail feedbackDetail = getItem(position);

        ViewHolder viewHolder;

        if (convertView == null) {

            convertView = BoundViewHelper.boundView(viewHolder = new ViewHolder(), ScaleScreenHelperFactory.getInstance().loadView((ViewGroup) layoutInflater.inflate(R.layout.item_feedback_detail_list, null)));

            convertView.setTag(viewHolder);
        } else {

            viewHolder = (ViewHolder) convertView.getTag();
        }

        viewHolder.feedback_detail_list_question_tv.setText(feedbackDetail.content);
        viewHolder.feedback_detail_list_question_time_tv.setText("日期：" + feedbackDetail.posttime);
        viewHolder.feedback_detail_list_answer_tv.setText(feedbackDetail.reply);
        viewHolder.feedback_detail_list_answer_time_tv.setText("日期：" + feedbackDetail.recovery_time);

        Log.e("----", feedbackDetail.content + feedbackDetail.posttime + feedbackDetail.reply + feedbackDetail.recovery_time);

        return convertView;
    }

    class ViewHolder {

        @BoundView(R.id.feedback_detail_list_question_tv) private TextView feedback_detail_list_question_tv;
        @BoundView(R.id.feedback_detail_list_question_time_tv) private TextView feedback_detail_list_question_time_tv;
        @BoundView(R.id.feedback_detail_list_answer_tv) private TextView feedback_detail_list_answer_tv;
        @BoundView(R.id.feedback_detail_list_answer_time_tv) private TextView feedback_detail_list_answer_time_tv;

    }
}
